<template>
  <div>
    <van-address-list
      v-model="chosenAddressId"
      :list="pathlist"
      default-tag-text="默认"
      :address-info="list"
      @add="onAdd"
      @edit="onEdit"
      @select="onitem"
    />
  </div>
</template>

<script>
import { mapActions, mapGetters } from "vuex";
export default {
    data() {
        return {
            chosenAddressId: "1",
            list:[]
        }
    },
  methods: {
    ...mapActions({
      reqchangelist: "path/reqchangelist",
    }),
    // 点击添加地址
    onAdd() {
    //    console.log(111);
        this.$emit('add1')
    },
    // 点击编辑
    onEdit(item, index) {
        console.log(item);
      this.$emit('bianji',index)
    },
    // 选中地址,跳转订单
    onitem(item, index) {
      console.log(item, index);
      this.$router.push('/order?addressid='+item.id)
    },
  },
  computed: {
    ...mapGetters({
      userlist: "user",
      pathlist: "path/list",
    }),
  },
  mounted() {
    this.reqchangelist(this.userlist.uid);
  },
};
</script>

<style lang="less" scoped>
</style>